//观察者
class Watcher {
  constructor (wm, key, cb) {
    //传入wm实例和key，是为了创建watcher之后马上调用get()来然dep收集依赖
    this.$wm = wm
    this.$key = key
    //dep当前的watcher
    Dep.target = this
    //会调用get方法，让dep收集当前watcher
    let oldVal = wm[key]
    //收集完之后销毁，防止重复收集
    Dep.target = undefined

    this.cb = cb
  }

  update () {
    this.cb(this.$wm[this.$key])
  }
}
